package com.relatev.minecraft.TRAttribute;

import java.util.HashMap;
import java.util.Map;
import org.bukkit.configuration.serialization.ConfigurationSerializable;

public class AttributeValue implements ConfigurationSerializable {
    
    public AttributeValue(ValueType type, double value) {
        Type = type;
        Value = value;
    }
    
    @Override
    public String toString() {
        return Type + "-" + Value;
    }
    
    public ValueType Type;
    public double Value;
    
    @Override
    public Map<String, Object> serialize() {
        Map<String, Object> map = new HashMap();
        map.put("type", Type.name());
        map.put("value", Value);
        return map;
    }

    public static AttributeValue deserialize(Map<String, Object> map) {
        return new AttributeValue(ValueType.valueOf((String) map.get("type")), (double) map.get("value"));
    }
}
